package com.logicalthinking.socialmall.common.vo.responseVo.product;

import com.github.chenlijia1111.commonModule.common.responseVo.product.AdminProductVo;
import com.github.chenlijia1111.utils.common.constant.BooleanConstant;
import com.github.chenlijia1111.utils.core.annos.PropertyCheck;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;

import javax.persistence.Column;
import java.util.Objects;

/**
 * 产品详情对象
 *
 * @author Chen LiJia
 * @since 2020/2/19
 */
@ApiModel
@Setter
@Getter
public class SocialAdminProductVo extends AdminProductVo {

    /**
     * 运费
     */
    @ApiModelProperty(value = "运费")
    private Double freight;

    /**
     * 交易方式是否支持线上交易 0否1是
     */
    private Integer transactionTypeSupportOnline;

    /**
     * 交易方式是否支持当面交易 0否1是
     */
    private Integer transactionTypeSupportInperson;

    /**
     * 交易类型
     */
    @ApiModelProperty(value = "交易类型")
    private String transactionTypeName;

    /**
     * 发布地址
     */
    @ApiModelProperty(value = "发布地址")
    private String releaseAddress;


    public SocialAdminProductVo createTransactionTypeName() {
        StringBuilder sb = new StringBuilder();
        if (Objects.equals(BooleanConstant.YES_INTEGER, this.transactionTypeSupportOnline)) {
            sb.append("快递/");
        }
        if (Objects.equals(BooleanConstant.YES_INTEGER, this.transactionTypeSupportInperson)) {
            sb.append("当面交易");
        }
        String s = sb.toString();
        if (s.endsWith("/")) {
            s = sb.deleteCharAt(sb.length() - 1).toString();
        }
        this.transactionTypeName = s;
        return this;
    }

}
